<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="./css/fusionCharts.css" type="text/css" />
<script language="JavaScript" src="./js/FusionCharts.js"></script>
<script language="JavaScript" src="./js/sale-monitor.js"></script>
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	//start 定义一个javascript对象，用于存储销售漏斗数据
	function saleStage(id,name,rate){
		this.id = id;//销售阶段id
		this.name = name;//销售销售阶段名称
		this.rate = rate;//完成率
	}
	var saleStages = new Array();
	<c:forEach var="saleStage" items="${saleStages}">
		saleStages.push(new saleStage("${saleStage.stageCode}","${saleStage.stageName}","${saleStage.successRate}"));
	</c:forEach>
	/**
	saleStages.push(new saleStage(1,"销售阶段二","70"));
	saleStages.push(new saleStage(1,"销售阶段三","60"));
	saleStages.push(new saleStage(1,"销售阶段四","50"));
	saleStages.push(new saleStage(1,"销售阶段五","40"));
	saleStages.push(new saleStage(1,"销售阶段六","30"));
	*/
	//end
	
	function back(){
		window.location.href = "customerReport.html";
		window.location.target = "main";
	}
	
	function viewFunnel(){
		document.saleFunnelForm.action = "./saleFunnel.do";
		document.saleFunnelForm.target = "main";
		document.saleFunnelForm.submit();
	}
	
	function viewStageCustomer(id,currentPercent){
		if(currentPercent > 0.001){
			document.saleFunnelForm.action = "./saleFunnel.do?action=funnelCustomers&saleStageId="+id;
			document.saleFunnelForm.target = "fCustomerFrame";
			document.saleFunnelForm.submit();
		}
	}
-->
</script>
</head>
<body>
<form name="saleFunnelForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td valign="top">
				<table class="table_title1">
					<tr>
						<td class="title_lab">销售漏斗</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">阶段客户列表</td>
					</tr>
					<tr>
						<td valign="top">
							<iframe src="./saleFunnel.do?action=funnelCustomers" id="fCustomerFrame" name="fCustomerFrame" frameborder="0" scrolling="no" width="100%" 
								onload="this.height=fCustomerFrame.document.body.scrollHeight;"></iframe>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<table class="table_title2">
					<tr>
						<td valign="top" height="300" width="124" style="border-right: solid 2px #999999;">
							<table class="table" align="center">
								<tr><td class="title_lab">销售漏斗</td></tr>
								<tr><td height="10"></td></tr>
								<tr><td height="30">&nbsp;&nbsp;分析指标</td></tr>
								<tr>
									<td height="30">&nbsp;
										<select id="funnelTarget" name="funnelTarget" style="width: 105px;">
											<!-- 
											<option value="0">------请选择------</option>
											 -->
											<option value="1" <c:if test='${saleFunnelForm.funnelTarget == 1}'>selected</c:if> >客户数量</option>
											<option value="2" <c:if test='${saleFunnelForm.funnelTarget == 2}'>selected</c:if> >预测金额</option>
										</select>
									</td>
								</tr>
								<tr><td height="30">&nbsp;&nbsp;销售代表</td></tr>
								<tr>
									<td height="30">&nbsp;
										<c:choose>
											<c:when test="${isViewDeptSaleFunnelImage == 1}">
												<select id="salePersonId" name="salePersonId" style="width: 105px;">
													<!-- 
													<option value="-1">------请选择------</option>
													 -->
													<option value="0" <c:if test='${saleFunnelForm.salePersonId == 0}'>selected</c:if> >部门</option>
													<c:forEach var="user" items="${users}">
													<option value="${user.id}" <c:if test='${saleFunnelForm.salePersonId == user.id}'>selected</c:if> >${user.userName}</option>
													</c:forEach>
												</select>
											</c:when>
											<c:otherwise>
												<select id="salePersonId" name="salePersonId" style="width: 105px;">
													<option value="${userId}" <c:if test='${saleFunnelForm.salePersonId == userId}'>selected</c:if> >${userName}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
												</select>
											</c:otherwise>
										</c:choose>
									</td>
								</tr>
								<tr><td height="30">&nbsp;&nbsp;分析周期</td></tr>
								<tr>
									<td height="30">&nbsp;
										<select id="time" name="time" style="width: 105px;">
											<!-- 
											<option value="0">------请选择------</option>
											 -->
											<option value="1" <c:if test='${saleFunnelForm.time == 1}'>selected</c:if> >按季</option>
											<option value="2" <c:if test='${saleFunnelForm.time == 2}'>selected</c:if> >按年</option>
										</select>
									</td>
								</tr>
								<tr>
									<td height="90" align="right">
										<input style="width: 100px;" class="btn_submit" type="button" value="生成图形" onclick="viewFunnel()"/>
										&nbsp;
									</td>
								</tr>
							</table>
						</td>
						<td align="center">
							<table class="table" style="text-align: center;height: 300px;">
								<tr>
									<td style="width: 315px;height: 325px;">
										<div id="chartdiv" align="left">漏斗分析图</div>
										<script type="text/javascript">
											saleFunnelImage(1,saleStages);
										</script>
										<center><img src="./images/fun.gif"/></center>
									</td>
									<td style="width: 355px;height: 325px;">
										<div id="chartdiv22" align="left">销售阶段图</div>
										<script type="text/javascript">
											saleFunnelImage1("chartdiv22","销售阶段图",saleStages);
										</script>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>	
</body>
</html>